package com.k2data.test.testng.listener.trans;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

/**
 * Annotation transform demo
 * 
 * The @Listeners annotation can contain any class that extends org.testng.ITestNGListener except IAnnotationTransformer and IAnnotationTransformer2. 
 * The reason is that these listeners need to be known very early in the process so that TestNG can use them to rewrite your annotations, 
 * therefore you need to specify these listeners in your testng.xml file.
 * 
 * @author wangchuan 2019-03-18
 *
 */
public class AnnotationTransformerExample {
	
	@DataProvider
    public static Object[][] dataProvider1(){
		return new Object[][] {
			{
				"provider 1 data 1"
			},
			{
				"provider 1 data 2"
			},
		};
	}
	
	@DataProvider
    public static Object[][] dataProvider2(){
		return new Object[][] {
			{
				"provider 2 data 1"
			},
			{
				"provider 2 data 2"
			},
		};
	}
	
	@BeforeSuite(description="@BeforeSuite")
	public void beforeSuite() {
		System.out.println("in beforeSuite");
	}
	
	@BeforeTest(description="@BeforeTest")
	public void beforeTest() {
		System.out.println("in beforeTest");
	}
	
	@BeforeMethod(description="@BeforeMethod")
	public void beforeMethod() {
		System.out.println("in beforeMethod");
	}
		
	@Test(description="@Test", dataProvider="dataProvider1", testName="testName")
	public void t(String param) {
		System.out.println("test method: " + param);
	}	

	@AfterMethod(description="@AfterMethod")
	public void afterMethod() {
		System.out.println("in afterMethod");
	}
	
	@AfterTest(description="@AfterTest")
	public void afterTest() {
		System.out.println("in afterTest");
	}
	
	@AfterSuite(description="@AfterSuite")
	public void afterSuite() {
		System.out.println("in after suite");
	}

}
